#include <stdio.h>
int sum(int n)
{
	 
	if(n<=3)
	{
		return n;
	}
	else
	{
		return sum(n-1)+sum(n-3);
	}
}


int main()
{
	int n;
	while(scanf("%d",&n)&&n)
	{
		printf("%d\n",sum(n));
		
	}
	return 0;
	
}
